package com.sina.interfaces.domain.user;

import com.sina.interfaces.core.domain.Domain;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;

/**
 * Created with IntelliJ IDEA
 * description:
 * 段浩杰 2017-10-23 21:37
 */
@Entity
@Table(name = "in_comment")
@DynamicInsert
@DynamicUpdate
public class Comment extends Domain {

    @Id
    @Column(name = "id", updatable = false)
    @GenericGenerator(name = "sequence_id", strategy = "com.sina.interfaces.core.sequence.IdGenerator")
    @GeneratedValue(generator = "sequence_id")
    @Min(1)
    private Long id;

    @OneToOne
    @JoinColumn(name = "user_id")
    private User user1;

    @NotNull
    @Column(name = "content")
    private String contents;

    @Column(name = "local_date")
    @NotNull
    private LocalDate localDate;

    @NotNull
    @Column(name = "ip")
    private String ip;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getUser1() {
        return user1;
    }

    public void setUser1(User user1) {
        this.user1 = user1;
    }

    public String getContents() {
        return contents;
    }

    public void setContents(String contents) {
        this.contents = contents;
    }

    public LocalDate getLocalDate() {
        return localDate;
    }

    public void setLocalDate(LocalDate localDate) {
        this.localDate = localDate;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }
}
